﻿using System;

namespace SuppKids.Core.Extensions
{
    public static class ExceptionExtensions
	{
		public static string GetDetailedMessage(this Exception ex)
		{
			return GetDetailedMessage(ex, @" ");
		}

		public static string GetDetailedMessage(this Exception ex, string separator)
		{
			var currentException = ex;

			var resultMessage = currentException.Message;
			while (currentException.InnerException != null)
			{
				resultMessage += separator + currentException.InnerException.Message;
				currentException = currentException.InnerException;
			}

			return resultMessage;
		}
	}
}
